//
// Created by Xu Xiao on 2022/10/14.
//

#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <unordered_map>
#include "Sln_L_1523.h"

#ifndef ALGORITHM_22_1_SOLUTION1014_H
#define ALGORITHM_22_1_SOLUTION1014_H


class Solution1014 {
public:
    static void L_Q1523() {
        Sln_L_1523 slnL1523l;
    }

    static void M_Q2545() {
        int t;
        scanf("%d", &t);
        while (t--) {
            int n;
            int x, y;
            scanf("%d", &n);
            vector<pair<int, int>> sch;
            sort(sch.begin(), sch.end(),
                 [](const pair<int, int> &s1, const pair<int, int> &s2) { return s1.first < s2.first; });
            vector<vector<int>> machines;
            for (int i = 0; i < n; i++) {
                scanf("%d %d", &x, &y);
                sch.emplace_back(x, y);
            }
            for (int i = 0; i < n; i++) {
                if (machines.empty()) {
                    machines.push_back({sch[i].first, sch[i].second});
                } else {
                    int j;
                    for (j = 0; j < machines.size(); j++) {
                        if (machines[j].back() <= sch[i].first) {
                            machines[j].push_back(sch[i].first);
                            machines[j].push_back(sch[i].second);
                            break;
                        }
                    }
                    if (j == machines.size()) {
                        machines.push_back(vector<int>{sch[i].first, sch[i].second});
                    }
                }
            }
            int tm = 0;
            for (auto &m: machines) {
                tm += (m.back() - m.front());
            }
            printf("%zu %d\n", machines.size(), tm);
        }
    }
};


#endif //ALGORITHM_22_1_SOLUTION1014_H
